<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>职位发布管理</title>
		<script src="js/global.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(function(){
				init();
			})
			function init(){
				$('#tabProfes').datagrid({    
				    url:'http://127.0.0.1:8080/findProfes',    
				    method:"post",
				    pagination:true,
				    striped:true,
				    toolbar:"#tb",
			   });
			}
			function caozuo(value,row,index){
				return "<a href='javascript:void(0)' onclick='upd("+index+")' class='easyui-linkbutton'>修改</a>   <a href='javascript:void(0)' onclick='del("+index+")' class='easyui-linkbutton'>删除</a>"
			}
			
			
			
			function zengjia(){
				$("#insertjigou_window").window("open");   
				$('#yijigouadd').combobox({    
				    url:'http://127.0.0.1:8080/selectbyfu?oParent=0',    
				    valueField:'oid',    
				    textField:'oname',
				    onChange:function(newValue, oldValue){
				    	$('#erjigouadd').combobox({    
						    url:'http://127.0.0.1:8080/selectbyfu?oParent='+newValue,    
						    valueField:'oid',    
						    textField:'oname',
						    onChange:function(newValue, oldValue){
						    	$('#sanjigouadd').combobox({    
								    url:'http://127.0.0.1:8080/selectbyfu?oParent='+newValue,    
								    valueField:'oid',    
								    textField:'oname'
								});
						    }
						});  
				    	
				    }
				});
			}
			function addjigoubaocun(){
				var yijigouadd  = $("#yijigouadd" ).combobox('getValue');
					if(yijigouadd=="--请选择--"){
						yijigouadd=0
					}
					var erjigouadd  = $("#erjigouadd" ).combobox('getValue');
					if(erjigouadd=="--请选择--"){
						erjigouadd=0
					}
					var sanjigouadd  = $("#sanjigouadd" ).combobox('getValue');
					if(sanjigouadd=="--请选择--"){
						sanjigouadd=0
					}
					var pLeixinadd  = $("#pLeixinadd" ).combobox('getValue');
					if(pLeixinadd=="--请选择--"){
						pLeixinadd=0
					}
				$.post(
					"http://127.0.0.1:8080/saveProfes", {
						pYi:yijigouadd,
						pEr:erjigouadd,
						pSan:sanjigouadd,
						pLeixin:pLeixinadd,
						pFenlei:$("#pFenleiadd").val(),
						pName:$("#pNameadd").val(),
						pRenshu:$("#pRenshuadd").val(),
						pDate:$("#pDateadd").val(),
						pDengji:$("#pDengjiadd").val(),
						pDjdate:$("#pDjdateadd").val(),
						pMianshu:$("#pMianshuadd").val(),
						pYaoqiu:$("#pYaoqiuadd").val(),
					},
					function(res) {
						if(res>0) {
							alert("增加成功"); 
							$("#insertjigou_window").window("close");
							$("#tabProfes").datagrid("reload");
						}
					}, "json");
				
				
			}
			function addjigouquxiao(){
				$("#insertjigou_window").window("close");
			}
			
			//修改
			function upd(index) {
				var data = $("#tabProfes").datagrid("getData");
				var row = data.rows[index]; 
				$("#updatejigouForm").form("load", row); 
				$("#updatejigou_window").window("open"); 
				
				
			}
			//删除机构
			function del(index) {
				var data = $("#tabProfes").datagrid("getData"); 
				var row = data.rows[index]; 
				
				$.messager.confirm('确认', '您确认想要删除记录吗？', function(r) {
					if(r) { 
						$.post("http://127.0.0.1:8080/deleteProfesById", {
							pId: row.pid	
						}, function(res) {
							if(res){
								alert("删除成功");
								$("#tabProfes").datagrid("load");
							}
						});
					}
				});

			}
			
			function updjigoubaocun(){
				$.post("http://127.0.0.1:8080/saveProfes", {
						pId:$("#pId").val(),
						pYi:$("#pYi").val(),
						pEr:$("#pEr").val(),
						pSan:$("#pSan").val(),
						pLeixin:$("#pLeixin").val(),
						pFenlei:$("#pFenlei").val(),
						pName:$("#pName").val(),
						pRenshu:$("#pRenshu").val(),
						pDate:$("#pDate").val(),
						pBiangeng:$("#pBiangeng").val(),
						pBgdate:$("#pBgdate").val(),
						pMianshu:$("#pMianshu").val(),
						pYaoqiu:$("#pYaoqiu").val(),
					},
					function(res) {
						if(res>0) {
							alert("修改成功"); 
							$("#updatejigou_window").window("close");
							$("#tabProfes").datagrid("reload");
						}
					}, "json");
			}
		</script>
	</head>
	<body>
		<div id="tb">
			<label for="name">薪资管理</label>  
			<a  href="javascript:void(0)" onclick="zengjia()" class="easyui-linkbutton">职位发布登记</a>  	
		</div>
		<table id="tabProfes" class="easyui-datagrid" style="width:400px;">
			<thead>
				<tr>
					<th data-options="field:'pid',title:'序号',hidden:true,align:'center'"></th>
					<th data-options="field:'pname',title:'职位名称'"></th>
					<th data-options="field:'pyi',title:'机构名称'"></th>
					<th data-options="field:'prenshu',title:'招聘人数'"></th>
					<th data-options="field:'pdjdate',title:'发布时间 '"></th>
					<th data-options="field:'pdate',title:'截止时间'"></th>
					<th data-options="field:'caozuo',title:'操作',align:'center',formatter:caozuo"></th>
				</tr>
			</thead>
		</table>
		<div id="insertjigou_window" class="easyui-window" title="增加新的职位" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:1000px;height:400px;padding:10px;">
			<table>
				<tr>
					<td>一级机构</td>
					<td><input id="yijigouadd" style="width:80px;"  class="easyui-combobox"  name="dept" value="--请选择--"></td>
					<td>二级机构</td>
					<td><input id="erjigouadd" style="width:80px;" class="easyui-combobox"  name="dept" value="--请选择--"></td>
					<td>三级机构</td>
					<td><input id="sanjigouadd" class="easyui-combobox" style="width:80px;" name="dept" value="--请选择--"> </td>
					<td>招聘类型</td>
					<td>
					<select id="pLeixinadd" class="easyui-combobox"  style="width:84px;">   
							<option value=""></option>
							<option value="1">男</option>   
							<option value="2">女</option>   
						</select>
					</td>
				</tr>
				<tr>
					<td>职业类型</td>
					<td><input  type="text"  id="pFenleiadd" style="width:80px;"></td>
					<td>职业名称</td>
					<td><input  type="text"  id="pNameadd" style="width:80px;"></td>
					<td>招聘人数</td>
					<td><input  type="text"  id="pRenshuadd" style="width:80px;"></td>
					<td>截止日期</td>
					<td><input  type="text"  id="pDateadd" style="width:80px;"></td>
				<tr>
					<td>登记人</td>
					<td><input  type="text"  id="pDengjiadd" style="width:80px;"></td>
					<td>登记时间</td>
					<td><input  type="text"  id="pDjdateadd" style="width:80px;"></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
				<tr>
					<td>职位描述</td>
					<td colspan="7"><input  type="text"  id="pMianshuadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>招聘要求</td>
					<td colspan="7"><input  type="text"  id="pYaoqiuadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<th><a href="javascript:void(0)" class="easyui-linkbutton" type="button" onclick="addjigoubaocun()">保存</a></th>
					<th><a href="javascript:void(0)" class="easyui-linkbutton" onclick="addjigouquxiao()">取消</a></th>
				</tr>
			</table>
		</div>	
		<div id="updatejigou_window" class="easyui-window" title="修改机构信息" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:400px;height:330px;padding:10px;">
			<form id="updatejigouForm">
				<table>
					<tr>
						<td>pid</td>
						<td><input  type="text"  id="pId" name="pid" style="width:80px;"></td>
						<td></td>
						<td></td>
						<td></td>
						<td></td>
						<td></td>
						<td></td>
					</tr>

					<tr>
						<td>一级机构</td>
						<td><input  type="text"  id="pYi" name="pyi" style="width:80px;"></td>
						<td>二级机构</td>
						<td><input  type="text"  id="pEr" name="per" style="width:80px;"></td>
						<td>三级机构</td>
						<td><input  type="text"  id="pSan" name="psan" style="width:80px;"></td>
						<td>招聘类型</td>
						<td><input  type="text"  id="pLeixin" name="pleixin" style="width:80px;"></td>
					</tr>
					<tr>
						<td>职业类型</td>
						<td><input  type="text"  id="pFenlei" name="pfenlei" style="width:80px;"></td>
						<td>职业名称</td>
						<td><input  type="text"  id="pName" name="pname" style="width:80px;"></td>
						<td>招聘人数</td>
						<td><input  type="text"  id="pRenshu" name="prenshu" style="width:80px;"></td>
						<td>截止日期</td>
						<td><input  type="text"  id="pDate" name="pdateadd" style="width:80px;"></td>
					<tr>
						<td>变更人</td>
						<td><input  type="text"  id="pBiangeng" name="pbiangeng" style="width:80px;"></td>
						<td>变更时间</td>
						<td><input  type="text"   id="pBgdate" name="pbgdate" style="width:80px;"></td>
						<td></td>
						<td></td>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td>职位描述</td>
						<td colspan="7"><input  type="text"  id="pMianshu" name="pmianshu" style="width:560px;"></td>
						
					</tr>
					<tr>
						<td>招聘要求</td>
						<td colspan="7"><input  type="text"  id="pYaoqiu" name="pyaoqiu" style="width:560px;"></td>
						
					</tr>
					<tr>
						<th><a href="javascript:void(0)" class="easyui-linkbutton" type="button" onclick="updjigoubaocun()">保存</a></th>
						<th><a href="javascript:void(0)" class="easyui-linkbutton" onclick="addjigouquxiao()">取消</a></th>
					</tr>
				</table>
			</form>
		</div>	
	</body>
</html>
